package com.wang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wang.pojo.TbTopicSimply;
import com.wang.service.TbTopicSimplyService;
import com.wang.mapper.TbTopicSimplyMapper;
import com.wang.utills.R;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 *
 */
@Service
@Transactional
public class TbTopicSimplyServiceImpl extends ServiceImpl<TbTopicSimplyMapper, TbTopicSimply>
    implements TbTopicSimplyService{

    @Resource
    private  TbTopicSimplyMapper tbTopicSimplyMapper;


    /*
    * 简单问卷的list
    *
    * */
    @Override
    public R findtopicsimplyall() {

        List<TbTopicSimply> list = tbTopicSimplyMapper.selectList(new QueryWrapper<>());
        List<TbTopicSimply> list1 =list.stream().filter(tbTopicSimply->{
            return tbTopicSimply.getDelFlag()==0;
        }).collect(Collectors.toList());
        return new R(200, "true", list1);
    }

    @Override
    public R deltopicbyid(TbTopicSimply tbTopicSimply) {
        //删除就是修改字段的
        tbTopicSimply.setDelFlag(1);
        this.tbTopicSimplyMapper.updateById(tbTopicSimply);
        //
        return new R(200, "true", null);
    }

}




